import { RouteRecordRaw } from "vue-router";
import Layout from "@/layout/index";

const publicRoutes: RouteRecordRaw[] = [
    {
        path: "/",
        component: Layout,
        redirect: "/home",
        children: [
            {
                path: "/home",
                component: () => import("@/views/home/index.vue"),
                name: "home"
            }
        ]
    }
]

const changeRoutes = (routes: RouteRecordRaw[]): RouteRecordRaw[] => {
    return routes.reduce((pre, cur) => {
        let item: Partial<RouteRecordRaw> = {
            name: cur.name,
            meta: cur.meta,
            path: cur.path
        }
        if (cur.children && cur.children.length > 1) {
            item.children = changeRoutes(cur.children)
        }
        pre.push(item as RouteRecordRaw)
        return pre
    }, [] as RouteRecordRaw[])
}

export const defaultRoutes = [...publicRoutes]
